package com.yc.Di.bean1;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author zwei
 * @create 2024-07-29 11:00
 */
@Component
public class Product {
    //几种注入方式
//    private int id=1;
//    private String pname="apple";


//    @Value("1")
//    private int id;
//    @Value("apple")
//    private String pname;

    @Value("${id}")
    private int id;               //${}占位符，读取属性值
    @Value("${pname}")
    private String pname;

    @Override
    public String toString() {
        return "Product{" +
                "id=" + id +
                ", pname='" + pname + '\'' +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }
}
